package cn.ad.model;

import java.util.Date;

public class TimeUpdateModel {
	
	private Date beforeTime;//修改前时间 a
	
	private Date afterTime;//修改后时间 b
	
	private int include; //判断执行大约小于还是等于 -1 小于 0等于  1 大于
	
	private int campaignId;//订单
	
	private String strategyId;//策略ID
	
	private boolean isUpdate = false;
	public TimeUpdateModel() {
		super();
	}

	public TimeUpdateModel(Date beforeTime, Date afterTime, int campaignId) {
		super();
		this.beforeTime = beforeTime;
		this.afterTime = afterTime;
		this.campaignId = campaignId;
	}

	/**
	 * 判断订单开始时间的更新
	 * @return
	 */
	public boolean getCampaignStartUpdate(){
		if(afterTime.before(beforeTime)){
			/*
			 * b<a && now<b
			 * 修改后的开始时间在之前订单的开始时间之前,并且开始时间在当前时间之后,需要将策略开始时间为a的，修改开始时间为b
			 */
			include = 0;
			return true;
		}else if(beforeTime.before(afterTime)){
			/*
			 * a<b && now<a
			 * 将策略开始时间<b的，修改开始时间为b 
			 */
			include = -1;
			beforeTime = afterTime;
			return true;
		}else{
			return false;
		}
	}

	/**
	 * 判断订单结束时间的更新
	 * @return
	 */
	public boolean getCampaignEndUpdate(){
		if(afterTime.before(beforeTime)){
			/*
			 * 将策略结束时间大于afterTime 的更新为 afterTime
			 */
			include = 1;
			beforeTime = afterTime;
			return true;
		}else if(beforeTime.before(afterTime)){
			/*
			 * a<b && now<a
			 * 将策略结束时间=startTime 的，修改结束时间为b 
			 */
			include = 0;
			return true;
		}else{
			return false;
		}
	}

	public Date getBeforeTime() {
		return beforeTime;
	}

	public void setBeforeTime(Date beforeTime) {
		this.beforeTime = beforeTime;
	}

	public Date getAfterTime() {
		return afterTime;
	}

	public void setAfterTime(Date afterTime) {
		this.afterTime = afterTime;
	}

	public int getInclude() {
		return include;
	}

	public void setInclude(int include) {
		this.include = include;
	}

	public int getCampaignId() {
		return campaignId;
	}

	public void setCampaignId(int campaignId) {
		this.campaignId = campaignId;
	}

	public boolean isUpdate() {
		return isUpdate;
	}

	public void setUpdate(boolean isUpdate) {
		this.isUpdate = isUpdate;
	}

	public String getStrategyId() {
		return strategyId;
	}

	public void setStrategyId(String strategyId) {
		this.strategyId = strategyId;
	}

}
